#include <cstdlib>
#include <iostream>

using namespace std;

int study_reference_define()
{
    //int& refInt;   //  Compile error, can not declare a reference without 
                     //- initializing it.   
    int i;    
    int& refInt=i;
    
    return 0;
} 

int study_reference_assignment()
{
    int object=0;
    int& refObject = object;
    
    cout << "refObject is a reference of object: " << endl
         << "object=" << object << ",refObject=" << refObject << endl
         << "change the value of object to 10. " << endl;
    object = 10;
    cout << "refObject=" << refObject << endl;         
    
    int newObject=100;
    refObject = newObject;
    cout << "assign a new object to the reference will not change the reference"
         << endl
         << "it will change the value of the object it refer to" << endl;
    cout << "object=" << object << ",refObject=" << refObject << endl;                  
    
    return 0;
}

int Study_Reference(int argc, char** argv)
{
   int rc=0;
   
   rc += study_reference_assignment(); 
   rc += study_reference_define();
   return rc;
}
